// $Id: buffers.h 4 2011-04-06 17:02:50Z cedric.shih@gmail.com $
/*
 * Copyright (C) 2010 Cedric Shih <cedric.shih@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef NIOBUFFERS_H_
#define NIOBUFFERS_H_

#ifdef __cplusplus
extern "C" {
#endif

enum niobuffers_type {
	NIO_BUFFERS_UNKNOWN,
	NIO_BUFFERS_CIRCULAR,
};

struct niobuffers *niobuffers_new(enum niobuffers_type type,
		unsigned int capacity);

void niobuffers_free(struct niobuffers *buffers);

void niobuffers_set_lock(struct niobuffers *buffers, pthread_mutex_t *lock);

struct niobuffer *niobuffers_create(
		struct niobuffers *buffers, size_t len);

int niobuffers_reset(struct niobuffers *buffers);

struct niobuffer *niobuffers_read(struct niobuffers *buffers);

struct niobuffers_stat {
	unsigned int count;
	unsigned int put;
	unsigned int dropped;
};

int niobuffers_stat(struct niobuffers *buffers,
		struct niobuffers_stat *stat);

#ifdef __cplusplus
}
#endif

#endif /* NIOBUFFERS_H_ */
